package logic

import (
	"context"
	"manager/model/mysql"

	"manager/merchantmanager/internal/svc"
	"manager/merchantmanager/merchantmanager"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowLogic {
	return &ShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShowLogic) Show(in *merchantmanager.RequestShow) (*merchantmanager.ResponseShow, error) {
	// todo: add your logic here and delete this line
	var data mysql.Merchant
	mysql.DB.Where("id=?", in.MerchantID).First(&data)
	return &merchantmanager.ResponseShow{
		MerchantID:    int64(data.MerchantID),
		MerchantName:  data.MerchantName,
		MerchantTypes: data.MerchantTypes,
		MerchantTime:  data.MerchantTime,
	}, nil
}
